import fetchRequest, { fetchStreamRequest, fetchDownload } from '@/utils/fetchRequest'

const id = '6a813599-3421-4a9d-858c-2355f51ffdbc'
// 登录方法
export function login(data) {
  return fetchRequest({
    url: '/console/api/login',
    method: 'post',
    data
  })
}

export function getProfile() {
  return fetchRequest({
    url: '/console/api/account/profile',
    method: 'get',
  })
}

export const fetchGenerationDownload = (data, fileName) => {
  return fetchDownload({
    url: '/download',
    method: 'post',
    data,
    fileName
  });
}


// 发送消息
export const fetchChat = (data, onProgress, onError) => {
  return fetchStreamRequest({
    url: `/console/api/installed-apps/${id}/chat-messages`,
    method: 'post',
    data,
    onProgress,
    onError
  });
}

// 对话记录
export const getConversationsList = (data) => {
  return fetchRequest({
    url: `/console/api/installed-apps/${id}/conversations`,
    method: 'get',
    data
  })
}


// 对话消息列表
export const chatMessages = (data) => {
  return fetchRequest({
    url: `/console/api/installed-apps/${id}/messages`,
    method: 'get',
    data
  })
}

// 重命名对话名称
export const conversationName = (conversationId, data) => {
  return fetchRequest({
    url: `/console/api/installed-apps/${id}/conversations/${conversationId}/name`,
    method: 'post',
    data
  })
}

// 删除对话
export const conversationDelete = (conversationId) => {
  return fetchRequest({
    url: `/console/api/installed-apps/${id}/conversations/${conversationId}`,
    method: 'delete',
  })
}
// 置顶对话
export const conversationPin = (conversationId, data) => {
  return fetchRequest({
    url: `/console/api/installed-apps/${id}/conversations/${conversationId}/pin`,
    method: 'PATCH',
    data
  })
}
// 取消置顶对话
export const conversationUnpin = (conversationId, data) => {
  return fetchRequest({
    url: `/console/api/installed-apps/${id}/conversations/${conversationId}/unpin`,
    method: 'PATCH',
    data
  })
}

// 建议问题
export const suggestedQuestions = (messageId, data) => {
  return fetchRequest({
    url: `/console/api/installed-apps/${id}/messages/${messageId}/suggested-questions`,
    method: 'get',
    data
  })
}
